<%@page import="com.award.model.User"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.award.model.Winner"%>
<%@page import="com.award.jdbc.dao.JdbcDao"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
JdbcDao jd=new JdbcDao();
List<Winner> winner_list = null;
winner_list=jd.queryAllWinner();
SimpleDateFormat bartDateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm");
User user = null;
%>

<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>历史记录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 <link href="./css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="./css/flat-ui.min.css" rel="stylesheet">
    <link href="./css/style.min.css" rel="stylesheet">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<jsp:include page="border/header.jsp" flush="true"></jsp:include>
<div class="container">
    <div class="title-page" style="text-align: left;">
        <h1>历史记录</h1>
    </div>
    <div id="history">
        <div class="info-history">已结束的活动:<strong class="ng-binding"><%= winner_list.size() %></strong></div>
        <section class="overflow-x">
            <table>
                <tbody id="tmpid_repeat_users">
                <% 
                for(Winner w:winner_list){ 
                user = jd.queryEmployeeByID(w.getWinnerID());
                %>
                <tr>
                    <td>
                        <span class="history-user-img"><img src="<%=user.getUserImgURL()%>"><!-- 图片，调用imgURL字段 --></span>
                        <span class="history-user-name"><%= user.getUsername() %></span>
                    </td>
                    <td><%= w.getCommodityName() %></td>
                    <td><%= bartDateFormat.format(w.getWinTime()) %></td>
                    <td>幸运编号：#<%= jd.queryRelationshipByOne(w.getWinnerID(), w.getCommodityID()).getSelectNum()%></td>
                    <td><a class="sbtn sbtn-red" href="./jsp/raffle.jsp?CommodityID=<%=w.getCommodityID()%>">查看中奖记录</a></td>
                </tr>
                <%} %>
                </tbody>
            </table>
        </section>
        <div class="centering-unit">
            <button class="sbtn sbtn-black" id="more">查看更多</button>
        </div>
    </div>
</div>
<footer>
    <div>
        Copyright &copy; 2017
    </div>
</footer>

<script src="./js/jquery.min.js"></script>
<script src="./js/flat-ui.min.js"></script>
<script src="./js/script.js"></script>
<script>
	$(document).ready(function(){
		$('.nav-item-history').addClass("active");
		$("#more").on("click", function(){
			var tmpstr = '<tr><td><span class="history-user-img"><img src="#UserImgURL#"></span><span class="history-user-name">#Username#</span></td><td>#CommodityName#</td><td>#WinTime#</td><td>幸运编号：##Num#</td><td><a class="sbtn sbtn-red" href="./jsp/raffle.jsp?CommodityID=#CommodityID()#">查看中奖记录</a></td></tr>';
			var genstr = "";
			$.get('URI', function(data){
				for(i = 0; i < data.xx.length; ++i){
					tmpstr.replace('#UserImgURL#', data.xx[i].UserImgURL);
					tmpstr.replace('#UserImgURL#', data.xx[i].UserImgURL);
					//.....
					genstr += tmpstr;
				}
				$('#tmpid_repeat_users').append(genstr);
			});
		});
	});
</script>
</body>
</html>
